home *** CD-ROM | disk | FTP | other *** search
- include lmacros.h
-
- ; Conditional ES save/restore macros not in lmacros.h
- pushes macro
- ifdef LONGPTR
- push es
- endif
- endm
-
- popes macro
- ifdef LONGPTR
- pop es
- endif
- endm
-
- assume ds:dataseg
- assume cs:codeseg
- public sssave,spsave,intstk
-
- ifdef FARPROC
- extrn doret:far,ecint_:far,getintds:far
- else
- extrn doret:near,ecint_:near,getintds:near
- endif
-
- ; ec0vec - Ethernet interrupt handler
- public ec0vec_
-
- ec0vec_ proc far
- push ds ; save on user stack
- call getintds ; establish interrupt data segment
-
- mov ds:sssave,ss ; stash user stack context
- mov ds:spsave,sp
-
- push ds
- pop ss
- lea sp,intstk+512
-
- push ax ; save user regs on interrupt stack
- push bx
- push cx
- push dx
- push bp
- push si
- push di
- push es
- push ds
- pop es
-
- mov ax,0 ; arg for service routine
- push ax
- call ecint_
- pop ax
- jmp doret
- ec0vec_ endp
-
- ; ec1vec - Ethernet interrupt handler
- public ec1vec_
-
- ec1vec_ proc far
- push ds ; save on user stack
- call getintds ; establish interrupt data segment
-
- mov ds:sssave,ss ; stash user stack context
- mov ds:spsave,sp
-
- push ds
- pop ss
- lea sp,intstk+512
-
- push ax ; save user regs on interrupt stack
- push bx
- push cx
- push dx
- push bp
- push si
- push di
- push es
- push ds
- pop es
-
- mov ax,1 ; arg for service routine
- push ax
- call ecint_
- pop ax
- jmp doret
- ec1vec_ endp
-
- ; ec2vec - Ethernet interrupt handler
- public ec2vec_
-
- ec2vec_ proc far
- push ds ; save on user stack
- call getintds ; establish interrupt data segment
-
- mov ds:sssave,ss ; stash user stack context
- mov ds:spsave,sp
-
- push ds
- pop ss
- lea sp,intstk+512
-
- push ax ; save user regs on interrupt stack
- push bx
- push cx
- push dx
- push bp
- push si
- push di
- push es
- push ds
- pop es
-
- mov ax,2 ; arg for service routine
- push ax
- call ecint_
- pop ax
- jmp doret
- ec2vec_ endp
-
- ; fast buffer I/O routines -- used by 3-COM Ethernet controller
-
- ; outbuf - put a buffer to an output port
- procdef outbuf,<<oport,word>,<obuf,ptr>,<ocnt,word>>
- pushf
- push si
- pushds
- mov dx,oport
- mov cx,ocnt
- ldptr si,obuf,ds ; ds:si = obuf
- cld
-
- ; If buffer doesn't begin on a word boundary, send the first byte
- test si,1 ; (buf & 1) ?
- jz obufeven ; no
- lodsb ; al = *si++;
- out dx,al ; out(dx,al);
- dec cx ; cx--;
- mov ocnt,cx ; save for later test
- obufeven:
- shr cx,1 ; cx = cnt >> 1; (convert to word count)
- ; Do the bulk of the buffer, a word at a time
- jcxz onobuf ; if(cx != 0){
- xb: lodsw ; do { ax = *si++; (si is word pointer)
- out dx,al ; out(dx,lowbyte(ax));
- mov al,ah
- out dx,al ; out(dx,hibyte(ax));
- loop xb ; } while(--cx != 0); }
- ; now check for odd trailing byte
- onobuf: mov cx,ocnt
- test cx,1
- jz ocnteven
- lodsb ; al = *si++;
- out dx,al
- ocnteven:
- popds
- pop si
- popf
- pret
- pend outbuf
-
- ; inbuf - get a buffer from an input port
- procdef inbuf,<<iport,word>,<ibuf,ptr>,<icnt,word>>
- pushf
- push di
- pushes
- mov dx,iport
- mov cx,icnt
- ldptr di,ibuf,es ; es:di = ibuf (es already set in small model)
- cld
-
- ; If buffer doesn't begin on a word boundary, get the first byte
- test di,1 ; if(buf & 1){
- jz ibufeven ;
- in al,dx ; al = in(dx);
- stosb ; *di++ = al
- dec cx ; cx--;
- mov icnt,cx ; icnt = cx; } save for later test
- ibufeven:
- shr cx,1 ; cx = cnt >> 1; (convert to word count)
- ; Do the bulk of the buffer, a word at a time
- jcxz inobuf ; if(cx != 0){
- rb: in al,dx ; do { al = in(dx);
- mov ah,al
- in al,dx ; ah = in(dx);
- xchg al,ah
- stosw ; *si++ = ax; (di is word pointer)
- loop rb ; } while(--cx != 0);
- ; now check for odd trailing byte
- inobuf: mov cx,icnt
- test cx,1
- jz icnteven
- in al,dx
- stosb ; *di++ = al
- icnteven:
- popes
- pop di
- popf
- pret
- pend inbuf
-
- end
-